package com.ccys.cms.controller.consultation;

import com.ccys.cms.service.consultation.BookingAppointmentWebService;
import com.ccys.common.constants.ContextConstants;
import com.ccys.common.util.Kit;
import com.ccys.common.vo.ResponseResult;
import com.ccys.db.dto.consultation.BookingDTO;
import com.ccys.db.entity.TblBooking;
import com.ccys.db.vo.consultation.BookingAppointmentDetailWebVO;
import com.ccys.db.vo.consultation.BookingAppointmentMemberBenefitList;
import com.ccys.db.vo.consultation.BookingAppointmentWebVO;
import com.ccys.db.vo.consultation.DockerSpecialisationListWebVO;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@Api(tags = "诊断与预约-Appointment management与Corporate&Insurance 下eap 中预约数据通用该类")
@RequestMapping("consultation")
public class BookingAppointmentWebController {

    @Autowired
    private BookingAppointmentWebService bookingAppointmentWebService;

    @GetMapping("bookingAppointment")
    @ApiOperation("获取列表")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "memId", value = "病人ID", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "doctorId", value = "医生ID", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "companyId", value = "公司ID", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "appointmentType", value = "预约类型 1in-clinic 2:video  3:text-based  对应Appointment    下面的 Platform type", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "clinicId", value = "诊所ID", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "appointmentStatus", value = "预约状态 1:pending 2:confirmed 3:cancelled", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "startTimeAppointment", value = "预约的时间开始时间(格式 yyyy-mm-dd)", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "endTimeAppointment", value = "预约的时间结束时间(格式 yyyy-mm-dd)", required = false, dataType = "string", paramType = "query"),

        @ApiImplicitParam(name = "id", value = "对象id", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "startTime", value = "开始时间(格式 yyyy-mm-dd)", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "endTime", value = "结束时间(格式 yyyy-mm-dd)", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "orderByStr", value = "排序字段（后端返回的字段  asc升序，desc 降序,加上end后缀。示例（createdOn降序排 则传值 createdOn descend））",paramType = "query"),
    })
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC,response = BookingAppointmentWebVO.class)
    })
    public ResponseResult listObjectsCms(HttpServletRequest request, HttpServletResponse response, @ApiIgnore BookingDTO dto) {
        return this.bookingAppointmentWebService.listObjectsCms(request, response, dto);
    }


    //选择关联的病人列表，医生列表 已处理
    @GetMapping("bookingAppointment/dockerSpecialisationList")
    @ApiOperation("查询预约管理医生关联科室信息列表")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "doctorId", value = "医生ID", required = false, dataType = "string", paramType = "query"),
    })
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC,response = DockerSpecialisationListWebVO.class)
    })
    public ResponseResult dockerSpecialisationList( @ApiIgnore BookingDTO dto) {
        return this.bookingAppointmentWebService.dockerSpecialisationList(dto);
    }
    @GetMapping("bookingAppointment/benefitList")
    @ApiOperation("查询预约管理病人关联benifit 与科室identification 信息（benifit）列表")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "memId", value = "病人id", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "specialisationId", value = "科室的identification 值", required = false, dataType = "string", paramType = "query"),
    })
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC,response = BookingAppointmentMemberBenefitList.class)
    })
    public ResponseResult memberBenefitList( @ApiIgnore BookingDTO dto) {
        return this.bookingAppointmentWebService.listBookingAppointmentMemberBenefit(dto);
    }
    @GetMapping("bookingAppointment/detail")
    @ApiOperation("查询预约管理详情")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "列表Id", required = false, dataType = "string", paramType = "query"),
    })
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC,response = BookingAppointmentDetailWebVO.class)
    })
    public ResponseResult getBookingAppointmentDetail( @ApiIgnore BookingDTO dto) {
        return this.bookingAppointmentWebService.getBookingAppointmentDetail(dto);
    }

    @PostMapping("bookingAppointment")
    @ApiOperation("添加")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "clinicId", value = "诊所ID", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "memId", value = "病人ID", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "doctorId", value = "医生ID", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "specialisationId", value = "Specialisation type 选择的科室ID", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "planType", value = "Profile 选择传问诊使用的配套类型", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "benefitId", value = "Profile 选择传问诊使用的benefitId", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "benefitMemberId", value = "Profile 选择传问诊使用的病人使用的benefit关联表id", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "acReasonId", value = "appointment 预约取消理由id", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "appointmentTime", value = "预约的开始时间", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "appointmentEndTime", value = "预约时段的结束时间", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "appointmentType", value = "预约类型 1in-clinic 2:video  3:text-based", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "appointmentNote", value = "预约留言", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "appointmentStatus", value = "预约状态 1:pending 2:confirmed 3:cancelled", required = false, dataType = "string", paramType = "query"),


    })
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC)
    })
    public ResponseResult save(@ApiIgnore TblBooking entity) {
        entity.setId(null);
        return this.bookingAppointmentWebService.change(entity);
    }


    @PutMapping("bookingAppointment")
    @ApiOperation("编辑")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "clinicId", value = "诊所ID", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "id", value = "预约管理id", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "memId", value = "病人ID", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "doctorId", value = "医生ID", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "specialisationId", value = "Specialisation type 选择的科室ID", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "planType", value = "Profile 选择传问诊使用的配套类型", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "benefitId", value = "Profile 选择传问诊使用的benefitId", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "benefitMemberId", value = "Profile 选择传问诊使用的病人使用的benefit关联表id", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "acReasonId", value = "appointment 预约取消理由id", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "appointmentTime", value = "预约的开始时间", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "appointmentEndTime", value = "预约时段的结束时间", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "appointmentType", value = "预约类型 1in-clinic 2:video  3:text-based", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "appointmentNote", value = "预约留言", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "appointmentStatus", value = "预约状态 1:pending 2:confirmed 3:cancelled", required = false, dataType = "string", paramType = "query"),

    })
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC)
    })
    public ResponseResult edit(@ApiIgnore TblBooking entity) {
        Kit.allParamValid(entity, "id");
        return this.bookingAppointmentWebService.change(entity);
    }


    @DeleteMapping("bookingAppointment")
    @ApiOperation("删除")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "ID号", required = true, dataType = "string", paramType = "query")
    })
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC)
    })
    public ResponseResult delete(@ApiIgnore TblBooking dto) {
        Kit.allParamValid(dto, "id");
        return this.bookingAppointmentWebService.delete(dto);
    }

}